export const generateColumnsFn = (actionRender) => {
  let columns = [
    {
      title: '单据号',
      key: 'recordNo',
      fixed: 'left',
      align: 'center',
      minWidth: 255,
      // tooltip: true
    },
    {
      title: '提交人',
      key: 'pusherName',
      align: 'center',
      minWidth: 100
    },
    {
      title: '提交部门',
      key: 'pusherDeptName',
      align: 'center',
      minWidth: 160
    },
    {
      title: '提交时间',
      key: 'pushTime',
      align: 'center',
      minWidth: 180,
      tooltip: true
    },
    {
      title: '所属区域',
      key: 'pusherAreaName',
      align: 'center',
      minWidth: 110
    },
    {
      title: '修改类型',
      key: 'commitTypeStr',
      align: 'center',
      minWidth: 110
    },
    {
      title: 'SPU编码',
      key: 'spuNo',
      align: 'center',
      minWidth: 110,
      ellipsis: true,
      tooltip: true
    },
    {
      title: '商品名称',
      key: 'productNameFinal',
      align: 'center',
      minWidth: 110,
      tooltip: true
    },
    {
      title: '商品条数',
      key: 'productCount',
      align: 'center',
      minWidth: 100
    },
    {
      title: '状态',
      key: 'commitStateStr',
      align: 'center',
      minWidth: 120
    },
    {
      title: '操作',
      align: 'center',
      fixed: 'right',
      render: actionRender,
      minWidth: 200
    }
  ]
  return columns;
}
export const renderActionFn = (h, data) => {
  let { list, methods, row } = data;
  return (
    list.map(item => {
      const btnNames = {
        'Delete': '删除',
        'PackUp': '取回'
      }
      if (['Delete', 'PackUp'].includes(item.name)) {
        return <el-popconfirm
          style="margin: 10px"
          title={`确定要${btnNames[item.name]}当前单据吗？`}
          confirm-button-type="text"
          onConfirm={() => { methods({ item, row }) }}
        >
          <el-button
            slot="reference"
            type="text"
            size="large"
          >{item.label}
          </el-button>
        </el-popconfirm>
      }
      if (item.name == 'Delete') {
        return <el-popconfirm
          style="margin: 10px"
          title="确定要删除当前单据吗？"
          confirm-button-type="text"
          onConfirm={() => { methods({ item, row }) }}
        >
          <el-button
            slot="reference"
            type="text"
            size="large"
          >{item.label}
          </el-button>
        </el-popconfirm>
      }
      return <el-button
        type="text"
        size="large"
        onClick={() => { methods({ item, row }) }}
      >{item.label}</el-button>
    })
  )
}
